package ac.svn.accesscontrol.store;

import java.io.Serializable;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.Date;

public class AccessFile implements Serializable
{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private String accessFileLocation;
	private String accessFileName;
	private String notes;
	private Date firstUsed;
	public AccessFile(String accessFileLocation, String accessFileName) {
		super();
		this.accessFileLocation = accessFileLocation;
		this.accessFileName = accessFileName;
		firstUsed = new Date();
		new Date();
	}

	public AccessFile() {
		super();
		firstUsed = new Date();
		new Date();
	}

	public String getAccessFileLocation() {
		return accessFileLocation;
	}

	public void setAccessFileLocation(String accessFileLocation) {
		touch();
		this.accessFileLocation = accessFileLocation;
	}

	public String getAccessFileName() {
		return accessFileName;
	}

	public void setAccessFileName(String accessFileName) {
		touch();
		this.accessFileName = accessFileName;
	}

	public String getNotes() {
		return notes;
	}

	public void setNotes(String notes) {
		touch();
		this.notes = notes;
	}

	@Override
	public String toString() {
		return "<HTML><b><i>" + accessFileName + "</b></i>[ " + accessFileLocation + " ][<i> 	" +
				"Created: " + getDate(firstUsed) +"</i>]";// +" Last Updated: " + getDate(updated);
	}
	
	public void touch()
	{
		new Date();
	}
	
	private String getDate(Date date)
	{
		if(null == date)
		{
			return "";
		}
		String pattern = "dd-MM-yy hh:mm:ss a ";
		Format format = new SimpleDateFormat(pattern);
		return format.format(date);
	}

}
